/*! \file
 * \brief Enter a brief description here.
 *
 * Enter a detailed description here. (optional)
 * \author Author (Ivo Wingelaar)
 * \date Date (2011)
 * \version Version (0.0.1)
 * \copyright Copyright (GNU LGPL v3)
 */

#ifndef __LYNX_WINDOW_MANAGER_HPP_INCLUDED__
#define __LYNX_WINDOW_MANAGER_HPP_INCLUDED__

#include "LynxCursorManager.hpp"
#include "LynxEventReceiver.hpp"
#include "LynxOSManager.hpp"
#include "LynxAudioManager.hpp"
#include "LynxVideoManager.hpp"
#include "LynxTimeManager.hpp"

namespace Lynx
{

/** struct           **/
/** WindowParameters **/
//! An struct containing the startup parameters.
struct WindowParameters
{
    /** constructor **/
    WindowParameters() :
        mWindowSize(Myth::Math::Vector2u(800, 600)),
        mAntiAliasing(0),
        mFullscreen(false),
        mVerticalSync(false),
        mLoadPlugins(false),
        mConsoleLog(true),
        mEventReceiver(0),
        mLogLevel(ELL_INFORMATION)
    {
        //
    }

    //! The size of the drawable area.
    Myth::Math::Vector2u mWindowSize;
    //! The antialiasing quality.
    uint8_t mAntiAliasing;
    //! Should the engine switch to fullscreen mode on startup?
    bool mFullscreen;
    //! Should the engine use vertical synchronization?
    bool mVerticalSync;
    //! Should the engine load plugins on startup?
    bool mLoadPlugins;
    //! Should the engine load the console-logger?
    bool mConsoleLog;
    //! The eventreceiver to connect with the engine or NULL.
    EventReceiver* mEventReceiver;
    //! The level of the logmanager on startup.
    LYNX_E_LOG_LEVEL mLogLevel;
};

/** class         **/
/** WindowManager **/
//! An interface providing access to windows.
class WindowManager : public virtual Myth::ReferenceCounter
{
public:
    /** virtual function **/
    /** run              **/
    //! Runs the window to update everything.
    /// \return bool
    ///         True is everything is allright, false if the window wants to close.
    /// \param  void
    virtual bool run(void) = 0;

    /** virtual function **/
    /** close            **/
    //! Signal the window to close itself.
    /// \return void
    /// \param  void
    virtual void close(void) = 0;

    /** virtual function **/
    /** yield            **/
    //! Signal the window to pause itself for the smallest time possible.
    /// \return void
    /// \param  void
    virtual void yield(void) = 0;

    /** virtual function **/
    /** sleep            **/
    //! Signal the window to sleep for a while.
    /// \return void
    /// \param    uint32_t milliseconds
    ///         The time to sleep in milliseconds.
    /// \param    bool pause_timer
    ///         Should the time pause itself whilest sleeping?
    virtual void sleep(uint32_t milliseconds,
                       bool pause_timer = false) = 0;

    /** virtual function      **/
    /** clear_system_messages **/
    //! Clears all the messages from the message queue.
    /// \return void
    /// \param  void
    virtual void clear_system_messages(void) = 0;

    /** const virtual function **/
    /** get_window_caption     **/
    //! Returns the caption of the window.
    /// \return std::wstring
    ///         The caption of the window.
    /// \param  void
    virtual std::wstring get_window_caption(void) const = 0;

    /** virtual function   **/
    /** set_window_caption **/
    //! Sets the caption of the window.
    /// \return void
    /// \param    std::wstring caption
    ///         The new caption to set.
    virtual void set_window_caption(std::wstring caption) = 0;

    /** const virtual function **/
    /** is_window_focused      **/
    //! Returns if the window is focused.
    /// \return bool
    ///         True if the window is focused, false otherwise.
    /// \param  void
    virtual bool is_window_focused(void) const = 0;

    /** const virtual function **/
    /** is_window_fullscreen   **/
    //! Returns if the window is fullscreen.
    /// \return bool
    ///         True if the window is fullscreen, false otherwise.
    /// \param  void
    virtual bool is_window_fullscreen(void) const = 0;

    /** virtual function **/
    /** set_gamma_ramp   **/
    //! Sets the gamma ramp of the window.
    /// \return bool
    ///         True if the call succeeded, false otherwise.
    /// \param    float red
    ///         The red ramp.
    /// \param    float green
    ///         The green ramp.
    /// \param    float blue
    ///         The blue ramp.
    /// \param    float brightness
    ///         The brightness ramp.
    /// \param    float contrast
    ///         The contrast ramp.
    virtual bool set_gamma_ramp(float red,
                                float green,
                                float blue,
                                float brightness,
                                float contrast) = 0;

    /** virtual function **/
    /** get_gamma_ramp   **/
    //! Gets the gamma ramp of the window.
    /// \return bool
    ///         True if the call succeeded, false otherwise.
    /// \param    float& red
    ///         The red ramp.
    /// \param    float& green
    ///         The green ramp.
    /// \param    float& blue
    ///         The blue ramp.
    /// \param    float& brightness
    ///         The brightness ramp.
    /// \param    float& contrast
    ///         The contrast ramp.
    virtual bool get_gamma_ramp(float& red,
                                float& green,
                                float& blue,
                                float& brightness,
                                float& contrast) = 0;

    /** virtual function     **/
    /** post_event_from_user **/
    //! Posts an event from the user.
    /// \return bool
    ///         True if the event was absorbed, false otherwise.
    /// \param    const Event &event
    ///         The event you want to post.
    virtual bool post_event_from_user(const Event& event) = 0;

    /** const virtual function **/
    /** get_event_receiver     **/
    //! Returns the eventreceiver.
    /// \return EventReceiver*
    ///         The eventreceiver.
    /// \param  void
    virtual EventReceiver* get_event_receiver(void) const = 0;

    /** virtual function   **/
    /** set_event_receiver **/
    //! Sets a new eventreceiver.
    /// \return void
    /// \param    EventReceiver *receiver
    ///         A pointer to the new eventreceiver.
    virtual void set_event_receiver(EventReceiver* receiver) = 0;

    /** virtual function           **/
    /** add_event_receiving_object **/
    //! Adds a event receiving object to the eventlist.
    /// \return void
    /// \param    EventReceivingObject* object
    ///         A pointer to the event receiving object you want to add.
    virtual void add_event_receiving_object(EventReceivingObject* object) = 0;

    /** const virtual function           **/
    /** get_event_receiving_object_count **/
    //! Returns amount of event receiving object that are loaded.
    /// \return uint32_t
    ///         The total amount of event receiving objects.
    /// \param  void
    virtual uint32_t get_event_receiving_object_count(void) const = 0;

    /** virtual function           **/
    /** get_event_receiving_object **/
    //! Returns a event receiving object.
    /// \return EventReceivingObject*
    /// \param    uint32_t index
    ///         A pointer to the event receiving object you want to add.
    virtual EventReceivingObject* get_event_receiving_object(uint32_t index) const = 0;

    /** const virtual function **/
    /** get_video_manager      **/
    //! Returns the pointer to the videomanager.
    /// \return VideoManager*
    ///         The pointer to the videomanager.
    /// \param  void
    virtual VideoManager* get_video_manager(void) const = 0;

    virtual Audio::AudioManager* get_audio_manager(void) const = 0;

    /** const virtual function **/
    /** get_log_manager        **/
    //! Returns the pointer to the logmanager.
    /// \return LogManager*
    ///         The pointer to the logmanager.
    /// \param  void
    virtual LogManager* get_log_manager(void) const = 0;

    /** const virtual function **/
    /** get_time_manager       **/
    //! Returns the pointer to the timemanager.
    /// \return TimeManager*
    ///         The pointer to the timemanager.
    /// \param  void
    virtual TimeManager* get_time_manager(void) const = 0;

    /** const virtual function **/
    /** get_cursor_manager     **/
    //! Returns the pointer to the cursormanager.
    /// \return CursorManager*
    ///         The pointer to the cursormanager.
    /// \param  void
    virtual CursorManager* get_cursor_manager(void) const = 0;

    /** const virtual function **/
    /** get_os_manager         **/
    //! Returns the pointer to the osmanager.
    /// \return OSManager*
    ///         The pointer to the osmanager.
    /// \param  void
    virtual OSManager* get_os_manager(void) const = 0;
};

} // namespace Lynx

#endif // __LYNX_WINDOW_MANAGER_HPP_INCLUDED__
